/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.hero.web.dao;

import java.util.List;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import com.hero.web.entity.BaseExample;
import com.hero.web.entity.Pagination;

/**
 *
 * @author Volcano
 */
public abstract class IbatisBaseDao<T,E>
{
	
	/**
	 * 分布式事务
	 */
	private SqlMapClientTemplate jtaSqlMapClientTemplate;
	
    public SqlMapClientTemplate getJtaSqlMapClientTemplate() {
		return jtaSqlMapClientTemplate;
	}

	public void setJtaSqlMapClientTemplate(
			SqlMapClientTemplate jtaSqlMapClientTemplate) {
		this.jtaSqlMapClientTemplate = jtaSqlMapClientTemplate;
	}

	protected SqlMapClientTemplate sqlMapClientTemplate;
    public SqlMapClientTemplate getSqlMapClientTemplate() {
        return sqlMapClientTemplate;
    }

    public void setSqlMapClientTemplate(
            SqlMapClientTemplate sqlMapClientTemplate) {
        this.sqlMapClientTemplate = sqlMapClientTemplate;
    }
    public IbatisBaseDao() {
        super();
    }
    
    
    /**
     * 默认实现
     * @param example
     * @return
     */
    public int countByExample(E example)
    {
    	throw new UnsupportedOperationException("");
    }

    /**
     * 默认实现
     * @param example
     * @return
     */
    public List<T> selectByExample(E example)
    {
    	throw new UnsupportedOperationException("");
    }
    
    /**
     * 默认实现
     * @param example
     * @return
     */
	public List<T> selectByExamplePage(E example) {
		  BaseExample baseExample=(BaseExample) example;
	      Pagination page=baseExample.getPagination();
	      page.setTotalCount(countByExample(example));
	      if(page.isEmpty())
	      {
	          return null;
	      }
	      return selectByExample(example);
	}
	
	/**
     * 默认实现
     * @param example
     * @return
     */
	public int updateByExampleSelective(E example) {
		throw new UnsupportedOperationException("");
	}
	
	/**
     * 默认实现
     * @param example
     * @return
     */
	public int updateByExample(E example) {
		throw new UnsupportedOperationException("");
	}
	
	/**
	 * 默认实现
	 * @param id
	 * @return
	 */
	public int deleteByPrimaryKey(Integer id)
	{
		throw new UnsupportedOperationException("");
	}
	
	/**
	 * 默认实现
	 * @param id
	 * @return
	 */
	public T selectByPrimaryKey(Integer id)
	{
		throw new UnsupportedOperationException("");
	}
	
	/**
	 * 默认实现
	 * @param t
	 * @return
	 */
	public int updateByPrimaryKey(T t) {
		throw new UnsupportedOperationException("");
	}
}
